<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.14"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>NumCpp: power.hpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  $(document).ready(initResizable);
/* @license-end */</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="logo.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">NumCpp
   &#160;<span id="projectnumber">1.0</span>
   </div>
   <div id="projectbrief">A C++ implementation of the Python Numpy library</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.14 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('_functions_2power_8hpp_source.html','');});
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">Functions/power.hpp</div>  </div>
</div><!--header-->
<div class="contents">
<a href="_functions_2power_8hpp.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="preprocessor">#pragma once</span></div><div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;</div><div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_error_8hpp.html">NumCpp/Core/Error.hpp</a>&quot;</span></div><div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_core_2_shape_8hpp.html">NumCpp/Core/Shape.hpp</a>&quot;</span></div><div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_stl_algorithms_8hpp.html">NumCpp/Core/StlAlgorithms.hpp</a>&quot;</span></div><div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_types_8hpp.html">NumCpp/Core/Types.hpp</a>&quot;</span></div><div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_nd_array_8hpp.html">NumCpp/NdArray.hpp</a>&quot;</span></div><div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_utils_2power_8hpp.html">NumCpp/Utils/power.hpp</a>&quot;</span></div><div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;</div><div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;<span class="preprocessor">#include &lt;string&gt;</span></div><div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;</div><div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;<span class="keyword">namespace </span><a class="code" href="namespacenc.html">nc</a></div><div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;{</div><div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;    <span class="comment">//============================================================================</span></div><div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;    <span class="comment">// Method Description:</span></div><div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;<span class="comment"></span>    <span class="keyword">template</span>&lt;<span class="keyword">typename</span> dtype&gt;</div><div class="line"><a name="l00054"></a><span class="lineno"><a class="line" href="namespacenc.html#a1f059635ecfc805979db6973dfa29008">   54</a></span>&#160;    constexpr dtype <a class="code" href="namespacenc.html#a1f059635ecfc805979db6973dfa29008">power</a>(dtype inValue, <a class="code" href="namespacenc.html#a60efb2c7acad2ac3a9a9fcf1e93d0f49">uint8</a> inExponent) noexcept</div><div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;    {</div><div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;        <span class="keywordflow">return</span> <a class="code" href="namespacenc_1_1utils.html#a716a63ef8627c73f6cc4146481fcabdf">utils::power</a>(inValue, inExponent);</div><div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;    }</div><div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;</div><div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;    <span class="comment">//============================================================================</span></div><div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;    <span class="comment">// Method Description:</span></div><div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;<span class="comment"></span>    <span class="keyword">template</span>&lt;<span class="keyword">typename</span> dtype&gt;</div><div class="line"><a name="l00071"></a><span class="lineno"><a class="line" href="namespacenc.html#a1d499aca051987c91ddeeac011db55fd">   71</a></span>&#160;    <a class="code" href="classnc_1_1_nd_array.html">NdArray&lt;dtype&gt;</a> <a class="code" href="namespacenc.html#a1f059635ecfc805979db6973dfa29008">power</a>(<span class="keyword">const</span> <a class="code" href="classnc_1_1_nd_array.html">NdArray&lt;dtype&gt;</a>&amp; inArray, <a class="code" href="namespacenc.html#a60efb2c7acad2ac3a9a9fcf1e93d0f49">uint8</a> inExponent) noexcept</div><div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;    {</div><div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;        <a class="code" href="classnc_1_1_nd_array.html">NdArray&lt;dtype&gt;</a> returnArray(inArray.shape());</div><div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;        <a class="code" href="namespacenc_1_1stl__algorithms.html#a65dada83abf2bf7a4fe6bd5a7b00624e">stl_algorithms::transform</a>(inArray.cbegin(), inArray.cend(), returnArray.begin(),</div><div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;            [inExponent](dtype inValue) noexcept -&gt; dtype</div><div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;            {</div><div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;                <span class="keywordflow">return</span> <a class="code" href="namespacenc.html#a1f059635ecfc805979db6973dfa29008">power</a>(inValue, inExponent);</div><div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;            });</div><div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;</div><div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;        <span class="keywordflow">return</span> returnArray;</div><div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;    }</div><div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;</div><div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;    <span class="comment">//============================================================================</span></div><div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;    <span class="comment">// Method Description:</span></div><div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;<span class="comment"></span>    <span class="keyword">template</span>&lt;<span class="keyword">typename</span> dtype&gt;</div><div class="line"><a name="l00095"></a><span class="lineno"><a class="line" href="namespacenc.html#ad09cd336cd7c12dd32a84c91654fa5d1">   95</a></span>&#160;    <a class="code" href="classnc_1_1_nd_array.html">NdArray&lt;dtype&gt;</a> <a class="code" href="namespacenc.html#a1f059635ecfc805979db6973dfa29008">power</a>(<span class="keyword">const</span> <a class="code" href="classnc_1_1_nd_array.html">NdArray&lt;dtype&gt;</a>&amp; inArray, <span class="keyword">const</span> <a class="code" href="classnc_1_1_nd_array.html">NdArray&lt;uint8&gt;</a>&amp; inExponents)</div><div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;    {</div><div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;        <span class="keywordflow">if</span> (inArray.<a class="code" href="classnc_1_1_nd_array.html#a232a5e8c426b629dcda9f9d52e8ce905">shape</a>() != inExponents.<a class="code" href="classnc_1_1_nd_array.html#a232a5e8c426b629dcda9f9d52e8ce905">shape</a>())</div><div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;        {</div><div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;            <a class="code" href="_error_8hpp.html#af2aff1172060367b9c5398fa097fa8fd">THROW_INVALID_ARGUMENT_ERROR</a>(<span class="stringliteral">&quot;input array shapes are not consistant.&quot;</span>);</div><div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;        }</div><div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;</div><div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;        <a class="code" href="classnc_1_1_nd_array.html">NdArray&lt;dtype&gt;</a> returnArray(inArray.<a class="code" href="classnc_1_1_nd_array.html#a232a5e8c426b629dcda9f9d52e8ce905">shape</a>());</div><div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;        <a class="code" href="namespacenc_1_1stl__algorithms.html#a65dada83abf2bf7a4fe6bd5a7b00624e">stl_algorithms::transform</a>(inArray.<a class="code" href="classnc_1_1_nd_array.html#a46a8bd2b5b14f75e80590fb11ece89ba">cbegin</a>(), inArray.<a class="code" href="classnc_1_1_nd_array.html#a01305da9771c34f86b419379ee986f3e">cend</a>(), inExponents.<a class="code" href="classnc_1_1_nd_array.html#a46a8bd2b5b14f75e80590fb11ece89ba">cbegin</a>(), returnArray.begin(),</div><div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;            [](dtype inValue, <a class="code" href="namespacenc.html#a60efb2c7acad2ac3a9a9fcf1e93d0f49">uint8</a> inExponent) noexcept -&gt; dtype</div><div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160;            {</div><div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160;                <span class="keywordflow">return</span> <a class="code" href="namespacenc.html#a1f059635ecfc805979db6973dfa29008">power</a>(inValue, inExponent);</div><div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160;            });</div><div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;</div><div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;        <span class="keywordflow">return</span> returnArray;</div><div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;    }</div><div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160;}</div><div class="ttc" id="namespacenc_1_1stl__algorithms_html_a65dada83abf2bf7a4fe6bd5a7b00624e"><div class="ttname"><a href="namespacenc_1_1stl__algorithms.html#a65dada83abf2bf7a4fe6bd5a7b00624e">nc::stl_algorithms::transform</a></div><div class="ttdeci">OutputIt transform(InputIt first, InputIt last, OutputIt destination, UnaryOperation unaryFunction) noexcept</div><div class="ttdef"><b>Definition:</b> StlAlgorithms.hpp:521</div></div>
<div class="ttc" id="_error_8hpp_html"><div class="ttname"><a href="_error_8hpp.html">Error.hpp</a></div></div>
<div class="ttc" id="namespacenc_html"><div class="ttname"><a href="namespacenc.html">nc</a></div><div class="ttdef"><b>Definition:</b> Coordinate.hpp:45</div></div>
<div class="ttc" id="classnc_1_1_nd_array_html_a232a5e8c426b629dcda9f9d52e8ce905"><div class="ttname"><a href="classnc_1_1_nd_array.html#a232a5e8c426b629dcda9f9d52e8ce905">nc::NdArray::shape</a></div><div class="ttdeci">Shape shape() const noexcept</div><div class="ttdef"><b>Definition:</b> NdArrayCore.hpp:3600</div></div>
<div class="ttc" id="classnc_1_1_nd_array_html_a46a8bd2b5b14f75e80590fb11ece89ba"><div class="ttname"><a href="classnc_1_1_nd_array.html#a46a8bd2b5b14f75e80590fb11ece89ba">nc::NdArray::cbegin</a></div><div class="ttdeci">const_iterator cbegin() const</div><div class="ttdef"><b>Definition:</b> NdArrayCore.hpp:1054</div></div>
<div class="ttc" id="_nd_array_8hpp_html"><div class="ttname"><a href="_nd_array_8hpp.html">NdArray.hpp</a></div></div>
<div class="ttc" id="_core_2_shape_8hpp_html"><div class="ttname"><a href="_core_2_shape_8hpp.html">Shape.hpp</a></div></div>
<div class="ttc" id="_utils_2power_8hpp_html"><div class="ttname"><a href="_utils_2power_8hpp.html">power.hpp</a></div></div>
<div class="ttc" id="_error_8hpp_html_af2aff1172060367b9c5398fa097fa8fd"><div class="ttname"><a href="_error_8hpp.html#af2aff1172060367b9c5398fa097fa8fd">THROW_INVALID_ARGUMENT_ERROR</a></div><div class="ttdeci">#define THROW_INVALID_ARGUMENT_ERROR(msg)</div><div class="ttdef"><b>Definition:</b> Error.hpp:38</div></div>
<div class="ttc" id="_stl_algorithms_8hpp_html"><div class="ttname"><a href="_stl_algorithms_8hpp.html">StlAlgorithms.hpp</a></div></div>
<div class="ttc" id="_types_8hpp_html"><div class="ttname"><a href="_types_8hpp.html">Types.hpp</a></div></div>
<div class="ttc" id="namespacenc_html_a60efb2c7acad2ac3a9a9fcf1e93d0f49"><div class="ttname"><a href="namespacenc.html#a60efb2c7acad2ac3a9a9fcf1e93d0f49">nc::uint8</a></div><div class="ttdeci">uint8_t uint8</div><div class="ttdef"><b>Definition:</b> Types.hpp:43</div></div>
<div class="ttc" id="namespacenc_1_1utils_html_a716a63ef8627c73f6cc4146481fcabdf"><div class="ttname"><a href="namespacenc_1_1utils.html#a716a63ef8627c73f6cc4146481fcabdf">nc::utils::power</a></div><div class="ttdeci">dtype power(dtype inValue, uint8 inPower) noexcept</div><div class="ttdef"><b>Definition:</b> Utils/power.hpp:46</div></div>
<div class="ttc" id="classnc_1_1_nd_array_html"><div class="ttname"><a href="classnc_1_1_nd_array.html">nc::NdArray</a></div><div class="ttdoc">Holds 1D and 2D arrays, the main work horse of the NumCpp library. </div><div class="ttdef"><b>Definition:</b> NdArrayCore.hpp:66</div></div>
<div class="ttc" id="classnc_1_1_nd_array_html_a01305da9771c34f86b419379ee986f3e"><div class="ttname"><a href="classnc_1_1_nd_array.html#a01305da9771c34f86b419379ee986f3e">nc::NdArray::cend</a></div><div class="ttdeci">const_iterator cend() const noexcept</div><div class="ttdef"><b>Definition:</b> NdArrayCore.hpp:1087</div></div>
<div class="ttc" id="namespacenc_html_a1f059635ecfc805979db6973dfa29008"><div class="ttname"><a href="namespacenc.html#a1f059635ecfc805979db6973dfa29008">nc::power</a></div><div class="ttdeci">constexpr dtype power(dtype inValue, uint8 inExponent) noexcept</div><div class="ttdef"><b>Definition:</b> Functions/power.hpp:54</div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_d44c64559bbebec7f509842c48db8b23.html">include</a></li><li class="navelem"><a class="el" href="dir_34171bd951b13a53aa9f237277a18e40.html">NumCpp</a></li><li class="navelem"><a class="el" href="dir_9051d82ec7b39b1c992f5bf2868571ca.html">Functions</a></li><li class="navelem"><a class="el" href="_functions_2power_8hpp.html">power.hpp</a></li>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.14 </li>
  </ul>
</div>
</body>
</html>
